<?php
require('config.php');

        $user_id=$_REQUEST['user_id'];
        $ypwd=$_REQUEST['ypwd'];
        $pwd=$_REQUEST['pwd'];
		$sql="select * from `".$oto."_users` where `userId`='".$user_id."' and userFlag='1' LIMIT 1";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$cha_mobile[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(!isset($cha_mobile))
		{
			$data[0]['pan']=-1;
			$data[0]['msg']="账号不存在";
		}
		else
		{
			$sjs=$cha_mobile[0]['loginSecret'];
			$userId=$cha_mobile[0]['userId'];
			$pwd=md5($pwd.$sjs);
			if(md5($ypwd.$sjs)!=$cha_mobile[0]['loginPwd'])
			{
				$data[0]['pan']=-2;
				$data[0]['msg']="原密码错误";
				echo json_encode($data);
				exit();
			}
            $sql="update ".$oto."_users set loginPwd='{$pwd}' where userId='{$userId}'";
			$result=$db->query($sql);
            if($result)
            {
            	$data[0]['pan']=1;
            }
            else
            {
				$data[0]['pan']=2;
				$data[0]['msg']="设置失败";
            } 
		}
		echo json_encode($data);
?>